package com.abaaba.project2.bean;

import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;


@Data
public class Collect {
    private Integer id;

    private Integer userId;

    private Integer valueId;

    private Byte type;

    private String addTime;

    private String updateTime;

    private Boolean deleted;

    public Collect() {
    }

    public Collect(Integer id, Integer userId, Integer valueId, Byte type, Date addTime, Date updateTime, Boolean deleted) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.id = id;
        this.userId = userId;
        this.valueId = valueId;
        this.type = type;
        this.addTime = simpleDateFormat.format(addTime);
        this.updateTime = simpleDateFormat.format(updateTime);
        this.deleted = deleted;
    }

    public void setAddTime(String addTime) {
        this.addTime = addTime.substring(0, addTime.lastIndexOf("."));
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime.substring(0, updateTime.lastIndexOf("."));
    }
}